Skip to main content

Container and Signature Service

Introduction

Container And Signature Microservice is service from Signing Services collection that organizes such important features as:

  • Signing container related actions:
    • Create signing container
    • Update signing container
    • Download signing container attachments
    • Download signing container
    • Get information about signing container
      • Sign container / PDF using qualified signature tools such as:
        • ID card
        • Smart-ID
        • Mobile-ID
        • E-Paraksts Mobile (ePM)
          • Sign PDF using non-qualified visual signature

Package content

  • Microservice package location: /DMSS/dmss-container-and-signature-services/.
  • Microservice delivery package includes separate folder for each microservice having same name as microservice executable .jar file. Each microservice has configuration application.yml file that should be adjusted to fit client needs.

Container Microservice package (folder dmss-container-and-signature-services) includes:

DMSS General Architecture

diagram

Digital Mind Signing Services (DMSS) is a collection of REST webservices. DMSS core services devloped based on Java Spring Boot framework. DMSS consists following core services (collections of specific functionalities):

  • DMSS Archive Services – REST Services for interfacing with various archive/storage systems. Main purpose is to put and retrieve documents to and from storages. Depending on archive type set of features can be extended to support versioning and metadata manipulations.
  • DMSS Archive Services Fallback Service – REST Services to store documents with requests in versioned folders generated by service. Service can be used in case main archive is down or in maintenance, documents and requests stored temporarily in fallback service. Once main archive up and running again documents automatically moved to main archive. Fallback service can be used as main archive as well. It means document will be stored in filesystem and document id generated by service.
  • DMSS Filesystem Archive Service – REST Services to store and retrieve documents from filesystem by document paths.
  • DMSS Document Generation Services – REST Service for generating document form input json data compiled with predefined template. Service includes FOP and BIRT template engines.
  • DMSS Digital Stamping Service – A service to interface certificate access from USB devices or HSM service providers.
  • DMSS Container and Signature Services – REST Services to create, sign, extract container type and pdf documents.
  • DMSS Process and Audit Service – REST Services to store signing workflow and events auditing records.
  • DMSS Internal Portal Proxy Service – REST Services for proxy internal portal requests to backend services like „Container and Signature Service“, „Process and Auditing Service“.
  • DMSS Authentication Service – REST Services for authentication including support for ID-Card, Mobile-ID and Smart-ID.

Document signing process diagram

schema

Configuration

In YAML configuration whitespace indentation is used for denoting structure. Table below is showing Container Microservice application.yml configuration parameters based on indent amount that could be used to configure microservice for a client needs:

NameDescriptionExample value
server.port
spring.servlet.multipart.maxFileSizeFile size that could not be exceed for servlet requests.100Mb
spring.servlet.multipart.maxRequestSizeTotal request size that could not be exceed for servlet requests.100Mb
spring.servlet.multipart.max-file-sizeFile size that could not be exceed for servlet requests.100Mb
spring.servlet.multipart.max-request-sizeTotal request size that could not be exceed for servlet requests.100Mb
spring.sleuth.web.client
spring.main.allow-bean-definition-overriding
signatureServices.signatureIsAdded AsynchronouslyToContainerSignature is added synchronously to container.false
signatureServices.timeout
signatureServices.cors.disabledCross-Origin Resource Sharing status.false
containerController.illegalCharsIllegal character for container name.[\\\\/:*?"<\\>^&]
containerController.createNewContainer.documentData.containerExtensionJsonKey
containerController.createNewContainer.documentData.certInHexJsonKey
containerController.createNewContainer.documentData.signatureProfileJsonKey
containerController.createNewContainer.documentData.documentFilenameJsonKey
containerController.createNewContainer.documentData.documentMimeTypeJsonKey
containerController.createNewContainer.documentData.containerMimeTypeJsonKey
containerController.createNewContainer.documentData.documentTypeJsonKey
containerController.createNewContainer.documentData.objectNameJsonKey
dmss-archive-services.baseUrlArchive service url.http://localhost:8090/api
dmss-archive-services.fallbackUrlFallback service url.http://localhost:8086/api
dmss-arhcive-services.forwardHttpHeadersList of forwarded http headers.OTCSTICKET, x-user-context
dmss-archive-services.configuration.container.defaultMimeTypeDefault MIME type.application/vnd.etsi.asic-e+zip
dmss-archive-services.configuration.container.defaultContainerExtensionDefault container extension..bdoc
dmss-archive-services.configuration.container.defaultDocumentType
dmss-archive-services.configuration.dataToSign.mimeType
dmss-archive-services.configuration.dataToSign.documentType
dmss-archive-services.configuration.dataToSign.fileExtension
dmss-archive-services.saveBinFilesAlwaysInFallback
dmss-archive-services.fileMimeTypesAndExtensionsmime.types file path.D:/DMSS/dmss-container-and-signature-services_V2/mime.types
smartId.hostUrlSmart-ID service host url.https://rp-api.smart-id.com/v1
smartId.relyingPartyUUIDClient ID that should registered and received from SK.00000000-0000-0000-0000-000000000000
smartId.relyingPartyNameCompany name that would be shown in Smart-ID popup.Digital Signing
smartId.vcChoice
smartId.displayTextExtra text that would be shown in Smart-ID popup.“Please sign!”
smartId.delay
mobile-id.truststorepathPath to trusted certificated.D:/DMSS/dmss-container-and-signature-services_V2/mobid.jks
mobile-id.fakeRequestsInTestAllowing fake requests in test mode.true
mobile-id.fakeReplacements.- idCode
mobile-id.fakeReplacements.replacementIdCode
mobile-id.fakeReplacements.replacementPNO
mobile-id.countries.EE / LT / LV
mobile-id.countries.EE / LT / LV.relyingPartyNameCompany name that would be shown in Mobile-ID popup.Digital Signing
mobile-id.countries.EE / LT / LV.hostUrlMobile-ID service url.https://tsp.demo.sk.ee/mid-api
mobile-id.countries.EE / LT / LV.relyingPartyUUIDClient ID that should be registered and received from SK.e18e72f7-4e7d-4e13-a309-82695135de2c
mobile-id.countries.EE / LT / LV.displayTextExtra text that would be shown in Smart-ID popup.“Please sign!”
hsm.pkcs11ModulePath
hsm.partitionPin
hsm.slotIndex
dmss-document-generation-service.baseUrlDocument generation service url.http://localhost:8083/api
dmss-document-generation-service.configuration.defaultMimeTypeDefault MIME type.application/pdf
dmss-document-generation-service.configuration.defaultExtensionDefault extension..pdf
dmss-digital-stamping-service.baseUrlDigital stamping service url.http://localhost:8084/api
hystrix.command.default.Execution -> isolation -> thread -> timeoutInMilliSeconds
digidoc4j.configuration.mode
digidoc4j.configuration.file
digidoc4j.configuration.preferAiaOcsp
digidoc4j.configuration.issuers.name url keystore password alias preferAiaOcspdigidoc4j issuer list.name: "E-ME SI (CA1)" url: "http://ocsp.sk.ee/_proxy" keystore: "" password: "" alias: "" preferAiaOcsp: false
pdf.signature.defaults.xAxisSignature X Axis location.100
pdf.signature.defaults.yAxisSignature Y Axis location.100
pdf.signature.defaults.zoomPercentZoom percent value.50
pdf.signature.defaults.signatureTextSignature text."Digitally signed by: {cn} \n{dnName} \nAt date: {date}"
pdf.signature.textImage.bySigned By
pdf.signature.textImage.inIn
pdf.signature.textImage.byAt
pdf.watermark.defaults.xAxisSignature X Axis location.100
pdf.watermark.defaults.yAxisSignature Y Axis location.700
pdf.watermark.defaults.transparencyTransparency level (0.0 – 1.0).1
pdf.watermark.defaults.colour r g bColor RGB values.r: 255 g: 0 b: 0
pdf.watermark.defaults.fontFont path."C:/Users/Brain/font/Pacifico-Regular.ttf"
pdf.watermark.defaults.fontsizeFont size.50
hazelcast.expireInMinutes
hazelcast.members
hazelcast.portHazelcast port.5777
hazelcast.kubernetes.enabledKubernetes enabled status.true
hazelcast.kubernetes.service-dnsKubernetes service dns.dmss-container-headless.default.svc.cluster.local
idCard.useContainerIdAsSesssionUse container ID as session.true
lvrtc.baseUriLVRTC service address.https://eidas.eparaksts.lv/
lvrtc.clientIdePM user ID.digimind
lvrtc.clientSecretClient secret provided by LVRTC.MbK4X6drcyKrJy4Q
lvrtc.authRedirectUriePM auth redirect URI.https://demo.trustlynx.com/identity?return=true
lvrtc.signRedirectUriePM sign redirect URI.https://demo.trustlynx.com/portal/
lvrtc.defaultLocaleDefault ePM language.lv
lvrtc.tspUrlTime stamp provider URL.https://tsa.eme.lv/
lvrtc.keystorePasswordKeystore password.DigitalMind
lvrtc.certAliasCertificate alias.ecm.digitalmind.lv (eparaksts ica 2017)
lvrtc.keystorePathKeystore path.D:/DMSS/dmss-container-and-signature-services/digitalmind.jks
lvrtc.certtruststorePathKCertificate trust store path.D:/DMSS/dmss-container-and-signature-services/cert.truststore.jks
logging.configLog file configuration XML path.D:/DMSS/dmss-container-and-signature-services /logback.xml
logging.level.rootLogging level.info / debug / trace.

Common usage scenarios, API sequence

Create container from existing document (Archive Microservice) and initiate Smart-ID signing (Container Microservice)

Creating container API:

  • POST /api/document/create (Archive Microservice)

post_request_1

Input parameters:

  • file (formData) – file or files array will be added to container
  • documentData (formData) – JSON structure describe in section “Common JSON structure for document creation”.

Request example:

post_request_2

Response:

  • JSON data including document id
<CreateDocumentResponse>
<id>cab7ae37-560f-43ab-9c9a-477c0dcce4ca</id>
<externalid>64b6c4cf-f4e5-42cf-8095-a42ce2e88c00</externalid>
</CreateDocumentResponse>

As the result of operation we have created container from external file / files and this container has been saved in Archive with specific ID cab7ae37-560f-43ab-9c9a-477c0dcce4ca. Now, using this ID we could initiate Smart-ID signing operation.

Initiate Smart-ID signing API:

  • PUT /api/signing/smart/container/{id}/sign (Container And Signature Microservice)

put_request_1

Input parameters:

  • id – container ID in Archive
  • signRequest – JSON structure with fields that are necessary for Smart-ID signing initiation

Request example:

put_request_2

Response:

{ 
result: 'SIGNING_STARTED',
sessionCode: 'acbf589d-c634-4942-a08d-5460181c3fa5',
verificationCode: '0204'
}

After this we need to poll Smart-ID session status API in order to understand what is the result of operation. There are multiple scenarios possible like user enters correct PIN / user refuses to enter PIN / timeout e.t.c.

Polling Smart-ID session API:

  • GET /api/signing/smart/session/{session}/status

get_request_1

Input parameters:

  • session – Session code that was received during Smart-ID signing initiation function

Request example:

get_request_2

Response:

{
result: ‘SIGNING_COMPLETED’
}

Status SIGNING_COMPLETED means the document was successfully signed.

Document download from Archive

Document downloading API:

  • GET/api/container/{id}/download

Input parameters:

  • Id (path)document id

Request example:

GET https://riga-app.digitalmind.lv:82/api/container/754c4c7e-18c2-4e3b-8607-4be39591bf5c/download

Response:

  • File if successful.

Running

It is recommended to use OpenJDK 11 (typically installed at /usr/lib/jvm/java-11-openjdk) for microservices execution.

Service execution command:

java -jar /opt/DMSS/ dmss-container-and-signature-services/

dmss-container-and-signature-services.jar --spring.config.location=/opt/DMSS/

dmss-container-and-signature-services /application.yml

These commands could be organized to run simultaneously as service / task scheduler based on OS and its possibilities (at example for windows – service startup commands could be organized in powershell script running on a system startup, for Linux – background service). The way how these commands are organized for running is decided individually by solution owner.

Debugging

In section 3 microservice has logging -> config setting that defines path to logback.xml file. This XML file has an appender section that defines the location of log files. Example of such section is:

debug_1

In current example logs are stored inside /opt/DMSS/logs/ folder. To define logging level for specific microservice, open corresponding application.yaml file and change logging -> level -> root setting to info* / debug / trace based on needs.

debug_2

External resources

Container microservice is using signing tools like SmartID, ePM e.t.c. that require access for external resources. It is important to have some web address based services available to be accessed from a machine where the solution is delivered. This list could be potentially changed as soon as each tool authority could change their service addresses, but typically we are informed some time before it happens. Current address and port list that should be opened from a microservice machine is:

  • Ports 80 and 443:
    • 82.140.152.1 elektroninisparasas.lt
    • 62.65.42.57 rp-api.smart-id.com
    • 147.67.34.30 ec.europa.eu
    • 212.70.163.131 trustlist.gov.lv
    • 62.65.42.42 ocsp.sk.ee
    • 195.80.123.217 sr.riik.ee
    • 62.65.42.41 mid.sk.ee
    • 62.65.42.51 tsa.sk.ee
    • sk.ee
    • c.sk.ee
    • sk.ee
    • aia.sk.ee
    • ocsp.eparaksts.lv
    • ocsp.eme.lv
  • Ports 80, 443 and 389
    • *.eme.lv

Document Changelog

VersionChangesDateChanged By
v1.0.0Initial version of User Manual25.08.2021Mihails Gordijenko